<script type="text/javascript">

	var tabstyle = {fontSize: "0.72em", 
					color: "black",
			 		backgroundColor: "#C1E0A0", 
			 		marginLeft: "4px", 
			 		width: "157px"
			 		};

	var tablist = [ new Tab("Based on your profile",tabstyle),
	                new Tab("What your friends like",tabstyle), 
	                new Tab("What other people like",tabstyle)
	    		  ];
	  
	var tabs = new TabsContainer(tablist, $("pagetabs"), '/<%= request.getRequestURI().split("/")[1] %>/');
	<% 
	if (session.getAttribute("force") != null){		
	%>	
		tabs.drawContainer("<%= (String) session.getAttribute("force") %>");
	<%
		session.removeAttribute("force");
	}
	else{
	%>
		tabs.drawContainer();
	<%
	}
	%>

	$("pagetitle").update("Recommendations");

	window.highlight = function(img){

		img.next().down().setStyle({color: "white", backgroundColor: "#494949"});
		
	};

	window.unhighlight = function(img){
		img.next().down().setStyle({color: "#555555", backgroundColor: "#ebebeb"});
		
	};

	window.musichighlight = function(img) {
		img.ancestors()[0].next().down().setStyle({color: "white", backgroundColor: "#494949"});
	};
	
	window.musicunhighlight = function(img) {
		img.ancestors()[0].next().down().setStyle({color: "#555555", backgroundColor: "#ebebeb"});
	};

	window.blind = function(span,elem){
		var elcontent = elem + "_content";
		var elload = elem + "_loaded";
		var message = "";	
		if (span.innerHTML === "Hide"){
			Effect.BlindUp(elcontent,{ queue: { position: 'end', scope: 'catscope' } });
			span.innerHTML = "Show";
			}
		else {
			Effect.BlindDown(elcontent,{ queue: { position: 'end', scope: 'catscope' } });
			span.innerHTML = "Hide";
		
		}
	};

	window.articles_latest = 0;
	window.music_latest = 0;
	window.videos_latest = 0;

	viewmore = function(what){

		var latest = 0;
		if (what === 'Articles'){
			++window.articles_latest;
			latest= window.articles_latest;
		}
		else if (what === 'Music'){
			++window.music_latest;
			latest = window.music_latest;
		}
		else {
			++window.videos_latest;
			latest = window.videos_latest;
		}
		
		var cat = what.toLowerCase();
		var requesturl = '/<%=request.getRequestURI().split("/")[1]%>/servlet/' + what;
		$(cat + "_viewmore").update("<img src='/<%=request.getRequestURI().split("/")[1]%>/images/fetching.gif' />").removeClassName("clickable").stopObserving('click');
		new Ajax.Request(requesturl,{

			parameters: {viewmore: "f", latest: latest},
			method: "post",
			onSuccess: function(transport){

				$("rec_" + cat + "_content_changeable").insert({bottom: transport.responseText});
				$(cat + "_viewmore").update("View more");
				Effect.Appear("rec_" + cat + "_page_" + latest, { queue: { position: 'end', scope: 'catscope' }});
				$(cat + "_viewmore").addClassName("clickable");
				Event.observe($(cat + "_viewmore"), "click", function(){viewmore(what);});
				
			}
			
		});


	};


	like = function(type,elem,url,title,id,source){

		elem.writeAttribute({onclick: ""});

		if (type === 0){
			elem.setStyle({backgroundImage: "url(/<%=request.getRequestURI().split("/")[1]%>/images/liked.png)"});
			elem.removeClassName("ilikebtn").addClassName("likedbtn");
		}
		else{
			elem.removeClassName("ilikevidbtn").addClassName("likedvidbtn");
			$(id + "_liked_locally").update("y");
		}

		new Ajax.Request("/<%=request.getRequestURI().split("/")[1]%>/servlet/iLike",{

			method: "get",
			parameters: {title: title, url: url, au: "site", source: source}
		
		});
		
	};

</script>

